import java.util.*;
class Solution1 {
    public static void merge(int A[], int m, int B[], int n) {
        int arr[]=new int[m+n];
        int i=0,j=0,num=0;
        while(i<=m-1 && j<=n-1) {    //遍历A数组//遍历B数组
            if(A[i]<=B[j]) {
                arr[num++]=A[i];
                i++;
            }else {
                arr[num++]=B[j];
                j++;
            }
        }
        while(i<=m-1) {
            arr[num++]=A[i];
            i++;
        }
        while(j<=n-1) {
            arr[num++]=B[j];
            j++;
        }
        for(int k=0;k<m+n-1;k++) {
            A[k]=arr[k];
        }


        System.out.println(A.toString());
    }


    public static void main(String[] args) {
        int A[]={1,2,3};
        int B[]={4,5,6};
        merge(A,3,B,3);
    }
}

public class Test3{

}